package com.situ.edu.dao.impl;


import com.situ.edu.dao.IXiDao;
import com.situ.edu.pojo.entity.User;
import com.situ.edu.pojo.entity.Xi;
import com.situ.edu.util.JDBCUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

public class XiDaoImpl implements IXiDao {
    private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());


    @Override
    public List<Xi> selectAll() {
        return template.query("select * from xi",
                new BeanPropertyRowMapper<>(Xi.class));
    }

    @Override
    public User selectById(int id) {
        return template.queryForObject("select * from user where id=?",
                new BeanPropertyRowMapper<>(User.class),id);
    }
}
